package cn.jbolt.admin.monitor.systemlog;

import cn.jbolt.core.api.JBoltApiBaseController;
import cn.jbolt.core.api.httpmethod.JBoltHttpGet;
import cn.jbolt.core.bean.JBoltDateRange;
import cn.jbolt.core.model.base.JBoltBaseModel;
import cn.jbolt.core.permission.CheckPermission;
import cn.jbolt.core.permission.UnCheckIfSystemAdmin;
import cn.jbolt.core.service.JBoltSystemLogService;
import cn.jbolt.core.service.base.JBoltBaseService;
import cn.jbolt.extend.permission.PermissionKey;
import com.jfinal.aop.Inject;
import com.jfinal.core.Path;
import com.jfinal.core.paragetter.Para;

@CheckPermission(PermissionKey.SYSTEMLOG)
@UnCheckIfSystemAdmin
@Path("/api/admin/systemLog")
public class SystemLogAdminController extends JBoltApiBaseController {
    @Inject
    private JBoltSystemLogService service;

    @Override
    protected JBoltBaseService<? extends JBoltBaseModel<?>> getModelService() {
        return service;
    }

    /**
     * 查看详情
     */
    @JBoltHttpGet
    public void index() {
        renderJBoltApiRet(findModelById());
    }

    @JBoltHttpGet
    public void datas(@Para(value = PAGE_PARAM_NAME, defaultValue = "1") Integer page,
                      @Para(value = PAGESIZE_PARAM_NAME, defaultValue = "15") Integer pageSize,
                      @Para(KEYWORDS_PARAM_NAME) String keywords,
                      @Para(DATE_RANGE_PARAM_NAME) JBoltDateRange dateRange
    ) {
        renderJBoltApiSuccessWithData(service.paginateAdminList(page, pageSize, keywords, dateRange));
    }
}
